/**********************************************************************************
// Color Header File
// 
// Creation:	07 Oct 2007
// Updated:		26 Apr 2011
// Compiler:	Visual Studio 2010
//
// Notes:		A color is a 32-bit value with Alpha, Red, 
//              Green and Blue components.
//
**********************************************************************************/

#ifndef _ANABELE_COLOR_H_
#define _ANABELE_COLOR_H_

// make classes and functions exportable to a DLL
#ifdef ANABELE_EXPORTS
#define DLL __declspec( dllexport ) 
#else
#define DLL __declspec( dllimport )
#endif

/**********************************************************************************/

#include <windows.h>
#include <d3d9.h>
#include "Types.h"

/**********************************************************************************/



class DLL Color
{
private:
	uchar alpha;								// transparency information
	uchar red;									// amount of red color
	uchar green;								// amount of green color
	uchar blue;									// amount of blue color

public:
	Color();									// default constructor
	Color(uchar r, uchar g, uchar b);			// build color with RGB
	Color(uchar a, uchar r, uchar g, uchar b);	// build color with ARGB
	Color& operator=(const Color& c);			// can assign a color to another
	Color& operator-(const int n);				// can subtract an int from a color

	ulong Encoded() const;						// return a 32-bit encoded color value	
	COLORREF Windows() const;					// return a Windows compatible COLORREF
	D3DCOLOR Direct3D() const;					// return a Direct3D compatible D3DCOLOR
};

/**********************************************************************************/
// InLine Member Functions

inline ulong Color::Encoded() const			// return a 32-bit encoded color value
{ return ((blue) + ((green) << 8) + ((red) << 16) + ((alpha) << 24)); }	

inline COLORREF Color::Windows() const		// return a Windows compatible COLORREF
{ return RGB(red, green, blue); }

inline D3DCOLOR Color::Direct3D() const    // return a Direct3D compatible D3DCOLOR
{ return ((((alpha)&0xff)<<24)|(((red)&0xff)<<16)|(((green)&0xff)<<8)|((blue)&0xff)); }

/**********************************************************************************/

#endif